<template>
	<view>
		<u-navbar :is-back="false" title="">
			<view class="slot-wrap">
				<view class="back-box" @click="back">
					<view class="icon">
						<u-icon name="arrow-left" color="#999999" size="30"></u-icon>
					</view>
					<view class="back">返回</view>

				</view>
				<view class="title-box">录入列表</view>
				<view class="more-box" @click="submit">提交信息</view>
			</view>
		</u-navbar>
		<view class="list">
			<view class="item" v-for="item in okAssistantList" :key="item.id">
				<BoundCoach @deleteAssistant="deleteAssistant" :type="5" :data="item" />
			</view>
		</view>
		<div class="btn-box">
			<view class="assistant-buttons">
				<view class="assistant-buttons-content">
					<button @click="ehcoAssistant">录入助教</button>
				</view>
			</view>
		</div>
	</view>
</template>

<script lang="ts" setup>
	import BoundCoach from '@/componnens/coach-card.vue'
	import { postHttpsRequset } from '@/public-ts-file/request';
	import { ref } from 'vue';
	import { onShow } from '@dcloudio/uni-app'

	// 当前已经录入的助教列表
	let okAssistantList = ref([])
	const getOkAssistantList = async () => {
		const parms = {
			path: '/shop/Zhujiao/get_zhulist',
			methods: 'post',
		}
		const res = await postHttpsRequset(parms)
		if (res.code == 200) {
			okAssistantList.value = res.data
		}
	}

	// 删除后重新调用接口
	const deleteAssistant = (bool : boolean) => {
		if (bool) getOkAssistantList()
	}

	onShow(() => {
		getOkAssistantList()
	})

	const submit = () => {
		uni.switchTab({
			url: '/pages/home/index'
		})
	}

	// 录入助教
	const ehcoAssistant = () => {
		uni.navigateTo({
			url: '/pages/index/echoAssistant'
		})
	}

	// 返回
	const back = () => uni.navigateBack()
</script>

<style lang="scss" scoped>
	.list {
		padding: 0 56rpx;
	}

	.top-box {
		display: flex;
		justify-content: flex-end;
		padding-bottom: 26rpx;

		.top-tip {
			display: flex;
			align-items: center;
			padding-right: 30rpx;
		}

		image {
			width: 30rpx;
			height: 30rpx;
			padding-top: 10rpx;
		}

		.text {
			opacity: 1;
			/** 文本1 */
			font-size: 10px;
			font-weight: 400;
			letter-spacing: 0px;
			line-height: 14.48px;
			color: rgba(153, 153, 153, 1);
			text-align: left;
			vertical-align: top;
			padding-left: 10rpx;
		}
	}

	.slot-wrap {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex: 1;

		.title-box {
			opacity: 1;
			/** 文本1 */
			font-size: 16px;
			font-weight: 400;
			letter-spacing: 0px;
			line-height: 23.17px;
			color: rgba(0, 0, 0, 1);
		}

		.more-box {
			opacity: 1;
			/** 文本1 */
			font-size: 10px;
			font-weight: 400;
			letter-spacing: 0px;
			line-height: 14.48px;
			color: rgba(0, 0, 0, 1);
			padding-right: 28rpx;
		}

		.back-box {
			display: flex;
			align-items: center;
			padding-left: 28rpx;

			.back {
				opacity: 1;
				/** 文本1 */
				font-size: 10px;
				font-weight: 400;
				letter-spacing: 0px;
				line-height: 14.48px;
				color: rgba(0, 0, 0, 1);
			}
		}

		/* 如果您想让slot内容占满整个导航栏的宽度 */
		/* flex: 1; */
		/* 如果您想让slot内容与导航栏左右有空隙 */
		/* padding: 0 30rpx; */

	}

	.btn-box {
		position: fixed;
		bottom: 12rpx;
		left: 0;
		right: 0;
		box-shadow: rgba(0, 0, 0, 0.06) 0px 2px 4px 0px inset;

		.assistant-buttons {
			margin: 0 30rpx;
			margin-top: 12rpx;

			.assistant-buttons-content {
				button {
					background-color: #3377FE;
					color: white;
					border-radius: 100rpx;
					font-size: 28rpx;
					padding: 8rpx 0;

					&::after {
						display: none;
					}
				}
			}
		}
	}
</style>